package com.w2cx.selenium.business;

import com.w2cx.selenium.base.DriverBase;
import com.w2cx.selenium.operate.InformationReviewOperate;
import org.openqa.selenium.WebElement;

import java.util.List;

public class InformationReviewProcess {

    DriverBase driver;
    InformationReviewOperate irh;
    int beforeNum,afterNum;
    String Id;
    public InformationReviewProcess(DriverBase driver){
        this.driver = driver;
        irh = new InformationReviewOperate(driver);
    }

   //审核资讯
    public void reviewInformation(){
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //点击“内容审核”菜单
        irh.clickContentReviewMenu();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //点击资讯审核菜单
        irh.clickInformationReviewMenu();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //获取第一条内容id
        Id = irh.getFirstInformaId().getText();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //点击第一条去审核
        irh.clickToReviewBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //点击审核按钮
        irh.clickReviewBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }



        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    //断言
    public boolean reviewSuccess(){

        WebElement element = irh.getFirstInformaId();
        List<WebElement> list = irh.getInformationList();
        for (int i=0;i<list.size();i++){
            if(list.get(i).getText().contains(Id)){
                return false;
            }
        }
        return true;
    }


}
